package com.rzj.sys_lab_assistant.service.impl;

import com.rzj.sys_lab_assistant.dao.StudentApplyMapper;
import com.rzj.sys_lab_assistant.entity.StudentApply;
import com.rzj.sys_lab_assistant.service.IStudentApplyService;
import com.rzj.sys_lab_assistant.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: sys_lab_assistant
 * @description:
 * @author: 作者
 * @create: 2021-07-01 15:30
 */
@Service
public class StudentApplyImpl implements IStudentApplyService {

    @Autowired
    StudentApplyMapper studentApplyMapper;

    TimeUtils timeUtils;

    @Override
    public List<StudentApply> studentAppliesList(int postId) {
        return studentApplyMapper.listStudentApplies(postId);
    }

    @Override
    public List<StudentApply> studentAppliesByNoList(String studentNo) {
        return studentApplyMapper.listStudentAppliesByNo(studentNo);
    }

    @Override
    public StudentApply getStudentApplyByNo(String studentNo) {
        return studentApplyMapper.getStudentApplyByNo(studentNo);
    }

    @Override
    public StudentApply getStudentApplyById(int id) {
        return studentApplyMapper.getStudentApplyById(id);
    }

    @Override
    public int addStudentApply(StudentApply studentApply) {
        studentApply.setApplyTime(timeUtils.getTime());
        studentApply.setApplyType(0);
        studentApply.setCreateTime(timeUtils.getTime());
        studentApply.setModifyTime(timeUtils.getTime());
        return studentApplyMapper.saveStudentApply(studentApply);
    }

    @Override
    public int updateStudentApply(StudentApply studentApply) {
        studentApply.setModifyTime(timeUtils.getTime());
        return studentApplyMapper.updateStudentApply(studentApply);
    }

    @Override
    public int updateStudentApplyStatus(StudentApply studentApply) {
        studentApply.setModifyTime(timeUtils.getTime());
        return studentApplyMapper.updateStudentApplyStatus(studentApply);
    }

    @Override
    public int delStudentApply(int id) {
        return studentApplyMapper.deleteStudentApply(id);
    }
}
